#include <sched.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  pid_t pid;
  int policy;
  const char* policy_str;
  struct sched_param sp;
  

  pid = atoi(argv[1]);
  policy = sched_getscheduler(pid);
  switch( policy ){
  case SCHED_RR :
    policy_str = "SCHED_RR";
    break;
  case SCHED_FIFO :
    policy_str = "SCHED_FIFO";
    break;
  case SCHED_OTHER :
    policy_str = "SCHED_OTHER";
    break;
  case SCHED_BATCH :
    policy_str = "SCHED_BATCH";
    break;
  case SCHED_IDLE :
    policy_str = "SCHED_IDLE";
    break;
  default:
    printf("Failed to match a policy : %d\n",policy);
    exit(-1);
  }
  
  if(sched_getparam(pid,&sp) == -1)
    printf("sched_getparam failed\n");
  printf("%d: %s %d\n",pid,policy_str,sp.sched_priority);

  return 0;
}
